<template>
	<view class="p20">
		<view class="p24 bg-fff radius20">
			<view class="pr tit-ac fs30 flex1">
				<text>提现金额</text>
			</view>
			<view class="flex border-b pt20 pb20">
				<view class="fs30">￥</view>
				<input placeholder="请输入提现金额" v-model="money" class="fs36" />
			</view>
			<view class="pt20 flex" v-if="type=='earnest'">
				<view class="color-999">保证金：</view>
				<view class="color-zs flex1" >{{$user.earnest_money||'0'}}</view>
			</view>
			<view class="pt20 flex" v-else>
				<view class="color-999">账户余额：</view>
				<view class="color-zs flex1" >{{$user.deposit||'0'}}</view>
			</view>
		</view>
		<view class="tc pt20 pb20">- 提现方式 -</view>
		<view class="radius20 bg-fff pl20 pr20">
			<view class="pt32 pb32 flex border-b" @click="method=item.type" v-for="(item,index) in payList"
				:key="index">
				<view class=" fs36 mr20">
					<u-icon name="checkmark-circle-fill" :color="$zs" v-if="method==item.type" />
					<u-icon name="checkmark-circle" v-else color="#999" />
				</view>
				<u-icon :name="item.icon" :color="item.color" size="64"></u-icon>
				<view class="flex1 ml20 ">{{item.name}}</view>
				<view class="color-999 td-b" @click="$jump(item.url)">{{item.bind_text}}</view>
			</view>
		</view>
		<view class="mt20">
			<u-parse :html="$config.withdraw_tips" :domain="$baseUrl"></u-parse>
		</view>
		<view class="h120"></view>
		<view class="pf left0 bottom0 w-max p20 h120 z-index2">
			<u-button type="warning" class="w-max" @click="submit">提现</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				payList: [],
				money: '',
				method: 'wechat',


				account: '',
				data: "",

				type: 'deposit'
			};
		},
		onLoad(e) {
			if (e.type) this.type = e.type
			this.init() 
		},
		methods: {
			init() {
				let arr = []
				arr.push(
					// #ifdef MP-WEIXIN 
					{
						"name": '微信小程序',
						icon: 'weixin-circle-fill',
						color: '#6bcc03',
						type: 'wechat'
					},
					// #endif
					// #ifdef APP-PLUS
					{
						"name": '微信小程序',
						icon: 'weixin-circle-fill',
						color: '#6bcc03',
						type: 'wechat',
						url: '/pages/my/set/userInfo',
						bind_text: this.$user.is_wechat_auth == 1 ? '已绑定' : '未绑定'
					}, {
						"name": '支付宝',
						icon: 'zhifubao-circle-fill',
						color: '#33c2fd',
						type: 'alipay',
						url: '/pages/my/set/userInfo',
						bind_text: this.$user.is_alipay_auth == 1 ? '已绑定' : '未绑定'
					},
					// #endif
				)
				arr.push({
					"name": '银行卡',
					icon: 'coupon-fill',
					color: '#fcbd71',
					type: 'bank',
					url: '/pages/my/set/bindBank',
					bind_text: this.$user.is_bank_bind == 1 ? '已绑定' : '未绑定'
				})
				this.method = arr[0].type //默认第一项
				this.payList = arr //支付数组
			},
			submit() {
				let params = {
					type: this.type,
					amount: this.money,
					method: this.method
				}
				this.$request('/master/money/apply', params).then(res => {
					this.$msg(res.msg)
					this.$z.navBack(1, 1000)
				})
			},
			getBalance() {
				this.$request('/master/withdraw/accountList').then(res => {
					this.data = res.data
					this.account = res.data?.data?.find(e => e.is_default == 1)
				})
			},
			setAccount() {
				uni.$once('setAccount', e => this.account = e)
				this.$jump('/pages/my/balance/bank', {
					type: 1,
					...this.$params
				})
			},
		}
	}
</script>

<style lang="scss">

</style>